;:sys36864
; dieses programm findet in einem basic programm alle
; goto und gosub befehle und prueft, ob sie definiert
; sind. <c> nss 19.12.1985
; (nicht fuer on befehl geeinget)
	;.opt oo
goto	= $89
gosub	= $8d
findline	= $a613
getnum	= $a96b
strout	= $ab1e
chrgot	= $79
chrptr	= chrgot+1
temp	= 2
start	= 43
axout	= $bdcd
return	= $aad7
frame	= 53280
screen	= frame+1
key	= 198
gosp	= 253
fehl	= 168
gotp	= 251
zeip	= 4
quote	= 167
chrout	= $ffd2
	*= $c000
	jmp init
text1	.byte "\x93\x99\x11steht das zu testende programm ab\x05 " 
	 .byt 0
text2	.byt 13 
	 .byte "\x99im speicher ? <taste>" 
	 .byt 0
text3	.byte "\x11\x99\x12fehler !\x11\x11" 
	 .byt 13,0
text4	.byte "\x93\x11test laeuft.....\x11\x11" 
	 .byt 13,0
text5	.byte "\x99\x91zeile \x05" 
	 .byt 0
text6	.byte "\x93\x99fertig !" 
	 .byt 13
	.byte "anzahl zeilen: \x05" 
	 .byt 0
text7	.byte "\x99anzahl fehler: \x05" 
	 .byt 0
text8	.byte "\x99anzahl gosubs: \x05" 
	 .byt 0
text9	.byte "\x99anzahl gotos : \x05" 
	 .byt 0
texta	.byte "\x11\x99<taste>" 
	 .byt 0
textb	.byte "<c> nig software service nss" 
	 .byt 0
get	inc temp
	bne l3
	inc temp+1
l3	ldy #0
	lda (temp),y
	rts
init	lda #0
	sta frame
	sta screen
	lda #<text1
	ldy #>text1
	jsr strout
	lda start+1
	ldx start
	jsr axout
	lda #<text2
	ldy #>text2
	jsr strout
	lda #0
	sta key
wait	lda key
	beq wait
	lda #<text4
	ldy #>text4
	jsr strout
	lda start
	sta temp
	lda start+1
	sta temp+1
	lda chrptr
	pha
	lda chrptr+1
	pha
	jsr null
	jsr test
	jsr waitkey
	pla
	sta chrptr+1
	pla
	sta chrptr
	lda #<text6
	ldy #>text6
	jsr strout
	ldx zeip
	lda zeip+1
	jsr axout
	jsr return
	lda #<text7
	ldy #>text7
	jsr strout
	ldx fehl
	lda fehl+1
	jsr axout
	jsr return
	lda #<text9
	ldy #>text9
	jsr strout
	ldx gotp
	lda gotp+1
	jsr axout
	jsr return
	lda #<text8
	ldy #>text8
	jsr strout
	ldx gosp
	lda gosp+1
	jsr axout
	jsr return
	jsr return
	ldx #39
	lda #"-"
dot	jsr chrout
	dex
	bpl dot
	lda #<textb
	ldy #>textb
	jmp strout
null	lda #0
	sta fehl
	sta fehl+1
	sta gosp
	sta gosp+1
	sta gotp
	sta gotp+1
	sta zeip
	sta zeip+1
	rts
test	ldy #1
	lda (temp),y
	bne noend
	rts
noend	lda #<text5
	ldy #>text5
	jsr strout
	lda #0
	sta quote
	inc zeip
	bne l1
	inc zeip+1
l1	ldy #2
	lda (temp),y
	tax
	iny
	lda (temp),y
	jsr axout
	jsr return
	lda temp
	clc 
	 adc #3
	sta temp
	bcc loop
	inc temp+1
loop	jsr get
	bne line
	jsr get
	jmp test
line	cmp #34
	bne noq
	lda quote
	eor #$ff
	sta quote
	jmp loop
noq	ldx quote
	bne loop
	cmp #gosub
	beq gos
	cmp #goto
	bne loop
	inc gotp
	bne l4
	inc gotp+1
l4	jmp check
gos	inc gosp
	bne l5
	inc gosp+1
l5	nop
check	jsr get
	lda temp
	sta chrptr
	lda temp+1
	sta chrptr+1
	jsr chrgot
	jsr getnum
	lda chrptr
	sec 
	 sbc #1
	sta temp
	lda chrptr+1
	sbc #0
	sta temp+1
	jsr findline
	bcs loop
	inc fehl
	bcc l6
	inc fehl+1
l6	lda #<text3
	ldy #>text3
	jsr strout
	jmp loop
waitkey	lda #<texta
	ldy #>texta
	jsr strout
	lda #0
	sta key
xxx	lda key
	beq xxx
	dec key
	rts
